package com.lczc.soa.service;

import com.lczc.soa.domain.Suggest;
import com.lczc.soa.mapper.SuggestMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SuggestServiceImpl implements SuggestService {

    @Autowired
    private SuggestMapper suggestMapper;

    public int saveSuggest(Suggest suggest) {
        if(suggest.getId()!=null){
            return suggestMapper.updateByPrimaryKeySelective(suggest);

        }else {
            return suggestMapper.insert(suggest);
        }
    }


    public Suggest findSuggestByPrimaryKey(String id) {
        return suggestMapper.selectByPrimaryKey(id);
    }

    public int deleteSuggest(String id) {
        return suggestMapper.deleteByPrimaryKey(id);
    }


    public List<Suggest> listSuggest() {
        return suggestMapper.selectAll();
    }

    public Suggest findSuggestByName(String userName) {
        return suggestMapper.selectByName(userName);
    }
}
